<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<f:view encoding="ISO-8859-1">
	<h:head>
		<title>Gêneros cadastrados</title>
		<h:outputStylesheet library="css" name="styles.css" />
	</h:head>
	<h:body>
		<h:form id="frmGen" styleClass="frm"
			rendered="#{loginBean.isLogged() and loginBean.hasPermission('CadGeneral')}">
			
			<ui:include src="../../templates/menu.xhtml" />
			
			<p:growl id="messages" showDetail="true" sticky="true"/>
			
			<p:panel id="cadPanelPrincipalGenre" header="Cadastro de gêneros de exemplares"	styleClass="cadPanelPrincipal">
				<h:outputLabel id="lblGenre" value="Gênero: " />
				<p:inputText id="txtGenre" label="Gênero" value="#{genreBean.description}" />
				<p:commandButton id="cmdButtonRegister" value="Cadastrar" actionListener="#{genreBean.onRegisterClick}" update=":frmGen:tblGenres :frmGen:messages" icon="ui-icon-disk"/>
			
				<p:dataTable id="tblGenres" var="gen" value="#{genreBean.genreList}" rowKey="#{gen.gecode}"	selection="#{genreBean.genre}" selectionMode="single">
					
					<p:column headerText="CÓDIGO">
						#{gen.gecode}
					</p:column>
					<p:column headerText="GÊNERO">
						#{gen.description}
					</p:column>
					
					<f:facet name="footer">
						<p:commandButton id="updButton" value="Atualizar" icon="ui-icon-pencil"/>
						<p:commandButton id="delButton" value="Remover" onclick="confDialog.show();" icon="ui-icon-trash"/>
					</f:facet>
					
				</p:dataTable>
			</p:panel>
			
			<p:confirmDialog id="confirmDialog" message="Você tem certeza que quer apagar o gênero selecionado?"
				header="Apagar gênero" severity="alert" widgetVar="confDialog">
				<p:commandButton id="deleteButton" value="Sim" update="messages :frmGen:tblGenres" oncomplete="confDialog.hide();" actionListener="#{genreBean.onDeleteClick}" />
                <p:commandButton id="cancelButton" value="Cancelar" onclick="confDialog.hide();" type="button" />
            </p:confirmDialog>
			
		</h:form>
		<h:form	rendered="#{!loginBean.isLogged() or !loginBean.hasPermission('CadGeneral')}">
			<h1 align="center">
				<h:outputText value="Acesso não autorizado a esta página!" />
			</h1>
			<h1 align="center">
				<h:graphicImage value="#{resource['images/general/forbidden.png']}" />
			</h1>
		</h:form>
		<ui:include src="../../templates/footer.xhtml" />
	</h:body>
</f:view>
</html>